package org.an.proj.contacts.config;

import android.support.annotation.NonNull;
import android.util.Log;
import com.orhanobut.logger.Logger;
import org.an.proj.contacts.util.DataParseUtil;

/**
 * Created by Fcy on 2016/3/19.<br/>
 */
public class LogUtil {

  private static String sTag = "LOG";
  private static boolean isDebug = Config.IS_LOG_ENABLE;

  public static void init(@NonNull String tag) {
    sTag = tag;
  }

  public static void i(String tag, String log) {
    if (isDebug) {
      Log.i(sTag, tag + ":" + log);
    }
  }

  public static void d(String tag, String log) {
    if (isDebug) {
      Log.d(sTag, tag + ":" + log);
    }
  }

  public static void logd(String tag, String log) {
    if (isDebug) {
      Logger.t(7).d(tag + ":" + log);
    }
  }

  public static void json(String tag, Object object) {
    if (isDebug) {
      Logger.t(tag).json(DataParseUtil.toJson(object));
    }
  }

  public static void json(String tag, String json) {
    if (isDebug) {
      Logger.t(tag).json(json);
    }
  }

  public static void e(String tag, String log) {
    if (isDebug) {
      Log.e(sTag, tag + ":" + log);
    }
  }

  public static void ef(String tag, String format, Object... args) {
    if (isDebug) {
      Log.e(sTag, tag + ":" + String.format(format, args));
    }
  }
}
